package com.compty.paint.manager;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import com.compty.core.hibernate.HibernateEntityDao;
import com.compty.paint.domain.LogInfo;

/**
 * @Todo:TODO
 * @author: zhuqh
 * @CreateTime:2011-11-25 下午02:59:51
 */
public class LogInfoManager extends HibernateEntityDao<LogInfo>{
	
	// 构造一个线程池
	ThreadPoolExecutor threadPool = new ThreadPoolExecutor(4,10, 3,
			TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(5),
			new ThreadPoolExecutor.DiscardOldestPolicy());
	
	public void writeLog(LogInfo logInfo){
		
		threadPool.execute(new Task(logInfo));
	}
	
	class Task implements Runnable{
		
		private LogInfo logInfo;
		
		public Task(LogInfo logInfo) {
			super();
			this.logInfo = logInfo;
		}

		public void run() {
			// TODO Auto-generated method stub
			save(logInfo);
		}
	}
	
}
